<?php
/*
 * Created on 25.01.2006
 *
 * if normal registered action:
 * action mapping used to find
 * 
 * if default error action or default action:
 * class name used to find
 * 
 * if callAction:
 *  if with class name:
 *      class name used to find
 *  if with class name and method
 *      concat (class name, method) used to find
 *
 */

class phpinchains_ViewMapping {

    var $mapping;
    var $env;
    var $action = '';
    var $medium = '';
    
    function phpinchains_ViewMapping (& $mapping) 
    {
        $this->mapping = & $mapping;
    }

    function setEnv (& $env)
    {
        $this->env     = & $env;
    }
    
    function setMedium ($medium)
    {
        $this->medium  = $medium;
    }
    
    function getMedium ()
    {
        return $this->medium;
    }
    
    function setAction ($action) 
    {
        $this->action = $action;
    }
    
    function getAction () 
    {
        return $this->action;
    }
    
    function findForward ($name) 
    {
        if (empty($this->action) || empty($this->mapping[$this->action][$name]))
        {
            $this->env->setAttribute("errorLocation", "doDispatch");
            $this->env->setAttribute("errorCause", "ViewNotMapped");
            $this->env->setAttribute("errorSubject", $this->action." . ".$name);
            return $this->mapping['defaulterror'];
        }
        return $this->mapping[$this->action][$name];
    }

}
?>
